

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>numpy &mdash; argoverse  documentation</title>
  

  
  
  
  

  
  <script type="text/javascript" src="../_static/js/modernizr.min.js"></script>
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
        <script type="text/javascript" src="../_static/jquery.js"></script>
        <script type="text/javascript" src="../_static/underscore.js"></script>
        <script type="text/javascript" src="../_static/doctools.js"></script>
        <script type="text/javascript" src="../_static/language_data.js"></script>
    
    <script type="text/javascript" src="../_static/js/theme.js"></script>

    

  
  <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../_static/graphviz.css" type="text/css" />
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../index.html" class="icon icon-home"> argoverse
          

          
          </a>

          
            
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <!-- Local TOC -->
              <div class="local-toc"></div>
            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../index.html">argoverse</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../index.html">Docs</a> &raquo;</li>
        
          <li><a href="index.html">Module code</a> &raquo;</li>
        
      <li>numpy</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <h1>Source code for numpy</h1><div class="highlight"><pre>
<span></span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">NumPy</span>
<span class="sd">=====</span>

<span class="sd">Provides</span>
<span class="sd">  1. An array object of arbitrary homogeneous items</span>
<span class="sd">  2. Fast mathematical operations over arrays</span>
<span class="sd">  3. Linear Algebra, Fourier Transforms, Random Number Generation</span>

<span class="sd">How to use the documentation</span>
<span class="sd">----------------------------</span>
<span class="sd">Documentation is available in two forms: docstrings provided</span>
<span class="sd">with the code, and a loose standing reference guide, available from</span>
<span class="sd">`the NumPy homepage &lt;https://www.scipy.org&gt;`_.</span>

<span class="sd">We recommend exploring the docstrings using</span>
<span class="sd">`IPython &lt;https://ipython.org&gt;`_, an advanced Python shell with</span>
<span class="sd">TAB-completion and introspection capabilities.  See below for further</span>
<span class="sd">instructions.</span>

<span class="sd">The docstring examples assume that `numpy` has been imported as `np`::</span>

<span class="sd">  &gt;&gt;&gt; import numpy as np</span>

<span class="sd">Code snippets are indicated by three greater-than signs::</span>

<span class="sd">  &gt;&gt;&gt; x = 42</span>
<span class="sd">  &gt;&gt;&gt; x = x + 1</span>

<span class="sd">Use the built-in ``help`` function to view a function&#39;s docstring::</span>

<span class="sd">  &gt;&gt;&gt; help(np.sort)</span>
<span class="sd">  ... # doctest: +SKIP</span>

<span class="sd">For some objects, ``np.info(obj)`` may provide additional help.  This is</span>
<span class="sd">particularly true if you see the line &quot;Help on ufunc object:&quot; at the top</span>
<span class="sd">of the help() page.  Ufuncs are implemented in C, not Python, for speed.</span>
<span class="sd">The native Python help() does not know how to view their help, but our</span>
<span class="sd">np.info() function does.</span>

<span class="sd">To search for documents containing a keyword, do::</span>

<span class="sd">  &gt;&gt;&gt; np.lookfor(&#39;keyword&#39;)</span>
<span class="sd">  ... # doctest: +SKIP</span>

<span class="sd">General-purpose documents like a glossary and help on the basic concepts</span>
<span class="sd">of numpy are available under the ``doc`` sub-module::</span>

<span class="sd">  &gt;&gt;&gt; from numpy import doc</span>
<span class="sd">  &gt;&gt;&gt; help(doc)</span>
<span class="sd">  ... # doctest: +SKIP</span>

<span class="sd">Available subpackages</span>
<span class="sd">---------------------</span>
<span class="sd">doc</span>
<span class="sd">    Topical documentation on broadcasting, indexing, etc.</span>
<span class="sd">lib</span>
<span class="sd">    Basic functions used by several sub-packages.</span>
<span class="sd">random</span>
<span class="sd">    Core Random Tools</span>
<span class="sd">linalg</span>
<span class="sd">    Core Linear Algebra Tools</span>
<span class="sd">fft</span>
<span class="sd">    Core FFT routines</span>
<span class="sd">polynomial</span>
<span class="sd">    Polynomial tools</span>
<span class="sd">testing</span>
<span class="sd">    NumPy testing tools</span>
<span class="sd">f2py</span>
<span class="sd">    Fortran to Python Interface Generator.</span>
<span class="sd">distutils</span>
<span class="sd">    Enhancements to distutils with support for</span>
<span class="sd">    Fortran compilers support and more.</span>

<span class="sd">Utilities</span>
<span class="sd">---------</span>
<span class="sd">test</span>
<span class="sd">    Run numpy unittests</span>
<span class="sd">show_config</span>
<span class="sd">    Show numpy build configuration</span>
<span class="sd">dual</span>
<span class="sd">    Overwrite certain functions with high-performance Scipy tools</span>
<span class="sd">matlib</span>
<span class="sd">    Make everything matrices.</span>
<span class="sd">__version__</span>
<span class="sd">    NumPy version string</span>

<span class="sd">Viewing documentation using IPython</span>
<span class="sd">-----------------------------------</span>
<span class="sd">Start IPython with the NumPy profile (``ipython -p numpy``), which will</span>
<span class="sd">import `numpy` under the alias `np`.  Then, use the ``cpaste`` command to</span>
<span class="sd">paste examples into the shell.  To see which functions are available in</span>
<span class="sd">`numpy`, type ``np.&lt;TAB&gt;`` (where ``&lt;TAB&gt;`` refers to the TAB key), or use</span>
<span class="sd">``np.*cos*?&lt;ENTER&gt;`` (where ``&lt;ENTER&gt;`` refers to the ENTER key) to narrow</span>
<span class="sd">down the list.  To view the docstring for a function, use</span>
<span class="sd">``np.cos?&lt;ENTER&gt;`` (to view the docstring) and ``np.cos??&lt;ENTER&gt;`` (to view</span>
<span class="sd">the source code).</span>

<span class="sd">Copies vs. in-place operation</span>
<span class="sd">-----------------------------</span>
<span class="sd">Most of the functions in `numpy` return a copy of the array argument</span>
<span class="sd">(e.g., `np.sort`).  In-place versions of these functions are often</span>
<span class="sd">available as array methods, i.e. ``x = np.array([1,2,3]); x.sort()``.</span>
<span class="sd">Exceptions to this rule are documented.</span>

<span class="sd">&quot;&quot;&quot;</span>
<span class="kn">from</span> <span class="nn">__future__</span> <span class="k">import</span> <span class="n">division</span><span class="p">,</span> <span class="n">absolute_import</span><span class="p">,</span> <span class="n">print_function</span>

<span class="kn">import</span> <span class="nn">sys</span>
<span class="kn">import</span> <span class="nn">warnings</span>

<span class="kn">from</span> <span class="nn">._globals</span> <span class="k">import</span> <span class="n">ModuleDeprecationWarning</span><span class="p">,</span> <span class="n">VisibleDeprecationWarning</span>
<span class="kn">from</span> <span class="nn">._globals</span> <span class="k">import</span> <span class="n">_NoValue</span>

<span class="c1"># We first need to detect if we&#39;re being called as part of the numpy setup</span>
<span class="c1"># procedure itself in a reliable manner.</span>
<span class="k">try</span><span class="p">:</span>
    <span class="n">__NUMPY_SETUP__</span>
<span class="k">except</span> <span class="ne">NameError</span><span class="p">:</span>
    <span class="n">__NUMPY_SETUP__</span> <span class="o">=</span> <span class="kc">False</span>

<span class="k">if</span> <span class="n">__NUMPY_SETUP__</span><span class="p">:</span>
    <span class="n">sys</span><span class="o">.</span><span class="n">stderr</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s1">&#39;Running from numpy source directory.</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
    <span class="k">try</span><span class="p">:</span>
        <span class="kn">from</span> <span class="nn">numpy.__config__</span> <span class="k">import</span> <span class="n">show</span> <span class="k">as</span> <span class="n">show_config</span>
    <span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
        <span class="n">msg</span> <span class="o">=</span> <span class="s2">&quot;&quot;&quot;Error importing numpy: you should not try to import numpy from</span>
<span class="s2">        its source directory; please exit the numpy source tree, and relaunch</span>
<span class="s2">        your python interpreter from there.&quot;&quot;&quot;</span>
        <span class="k">raise</span> <span class="ne">ImportError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span>

    <span class="kn">from</span> <span class="nn">.version</span> <span class="k">import</span> <span class="n">git_revision</span> <span class="k">as</span> <span class="n">__git_revision__</span>
    <span class="kn">from</span> <span class="nn">.version</span> <span class="k">import</span> <span class="n">version</span> <span class="k">as</span> <span class="n">__version__</span>

    <span class="n">__all__</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;ModuleDeprecationWarning&#39;</span><span class="p">,</span>
               <span class="s1">&#39;VisibleDeprecationWarning&#39;</span><span class="p">]</span>

    <span class="c1"># Allow distributors to run custom init code</span>
    <span class="kn">from</span> <span class="nn">.</span> <span class="k">import</span> <span class="n">_distributor_init</span>

    <span class="kn">from</span> <span class="nn">.</span> <span class="k">import</span> <span class="n">core</span>
    <span class="kn">from</span> <span class="nn">.core</span> <span class="k">import</span> <span class="o">*</span>
    <span class="kn">from</span> <span class="nn">.</span> <span class="k">import</span> <span class="n">compat</span>
    <span class="kn">from</span> <span class="nn">.</span> <span class="k">import</span> <span class="n">lib</span>
    <span class="kn">from</span> <span class="nn">.lib</span> <span class="k">import</span> <span class="o">*</span>
    <span class="kn">from</span> <span class="nn">.</span> <span class="k">import</span> <span class="n">linalg</span>
    <span class="kn">from</span> <span class="nn">.</span> <span class="k">import</span> <span class="n">fft</span>
    <span class="kn">from</span> <span class="nn">.</span> <span class="k">import</span> <span class="n">polynomial</span>
    <span class="kn">from</span> <span class="nn">.</span> <span class="k">import</span> <span class="n">random</span>
    <span class="kn">from</span> <span class="nn">.</span> <span class="k">import</span> <span class="n">ctypeslib</span>
    <span class="kn">from</span> <span class="nn">.</span> <span class="k">import</span> <span class="n">ma</span>
    <span class="kn">from</span> <span class="nn">.</span> <span class="k">import</span> <span class="n">matrixlib</span> <span class="k">as</span> <span class="n">_mat</span>
    <span class="kn">from</span> <span class="nn">.matrixlib</span> <span class="k">import</span> <span class="o">*</span>
    <span class="kn">from</span> <span class="nn">.compat</span> <span class="k">import</span> <span class="n">long</span>

    <span class="c1"># Make these accessible from numpy name-space</span>
    <span class="c1"># but not imported in from numpy import *</span>
    <span class="k">if</span> <span class="n">sys</span><span class="o">.</span><span class="n">version_info</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">&gt;=</span> <span class="mi">3</span><span class="p">:</span>
        <span class="kn">from</span> <span class="nn">builtins</span> <span class="k">import</span> <span class="nb">bool</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">,</span> <span class="nb">complex</span><span class="p">,</span> <span class="nb">object</span><span class="p">,</span> <span class="nb">str</span>
        <span class="n">unicode</span> <span class="o">=</span> <span class="nb">str</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="kn">from</span> <span class="nn">__builtin__</span> <span class="k">import</span> <span class="nb">bool</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">,</span> <span class="nb">complex</span><span class="p">,</span> <span class="nb">object</span><span class="p">,</span> <span class="n">unicode</span><span class="p">,</span> <span class="nb">str</span>

    <span class="kn">from</span> <span class="nn">.core</span> <span class="k">import</span> <span class="nb">round</span><span class="p">,</span> <span class="nb">abs</span><span class="p">,</span> <span class="nb">max</span><span class="p">,</span> <span class="nb">min</span>
    <span class="c1"># now that numpy modules are imported, can initialize limits</span>
    <span class="n">core</span><span class="o">.</span><span class="n">getlimits</span><span class="o">.</span><span class="n">_register_known_types</span><span class="p">()</span>

    <span class="n">__all__</span><span class="o">.</span><span class="n">extend</span><span class="p">([</span><span class="s1">&#39;__version__&#39;</span><span class="p">,</span> <span class="s1">&#39;show_config&#39;</span><span class="p">])</span>
    <span class="n">__all__</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">core</span><span class="o">.</span><span class="n">__all__</span><span class="p">)</span>
    <span class="n">__all__</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">_mat</span><span class="o">.</span><span class="n">__all__</span><span class="p">)</span>
    <span class="n">__all__</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">lib</span><span class="o">.</span><span class="n">__all__</span><span class="p">)</span>
    <span class="n">__all__</span><span class="o">.</span><span class="n">extend</span><span class="p">([</span><span class="s1">&#39;linalg&#39;</span><span class="p">,</span> <span class="s1">&#39;fft&#39;</span><span class="p">,</span> <span class="s1">&#39;random&#39;</span><span class="p">,</span> <span class="s1">&#39;ctypeslib&#39;</span><span class="p">,</span> <span class="s1">&#39;ma&#39;</span><span class="p">])</span>

    <span class="c1"># Filter out Cython harmless warnings</span>
    <span class="n">warnings</span><span class="o">.</span><span class="n">filterwarnings</span><span class="p">(</span><span class="s2">&quot;ignore&quot;</span><span class="p">,</span> <span class="n">message</span><span class="o">=</span><span class="s2">&quot;numpy.dtype size changed&quot;</span><span class="p">)</span>
    <span class="n">warnings</span><span class="o">.</span><span class="n">filterwarnings</span><span class="p">(</span><span class="s2">&quot;ignore&quot;</span><span class="p">,</span> <span class="n">message</span><span class="o">=</span><span class="s2">&quot;numpy.ufunc size changed&quot;</span><span class="p">)</span>
    <span class="n">warnings</span><span class="o">.</span><span class="n">filterwarnings</span><span class="p">(</span><span class="s2">&quot;ignore&quot;</span><span class="p">,</span> <span class="n">message</span><span class="o">=</span><span class="s2">&quot;numpy.ndarray size changed&quot;</span><span class="p">)</span>

    <span class="c1"># oldnumeric and numarray were removed in 1.9. In case some packages import</span>
    <span class="c1"># but do not use them, we define them here for backward compatibility.</span>
    <span class="n">oldnumeric</span> <span class="o">=</span> <span class="s1">&#39;removed&#39;</span>
    <span class="n">numarray</span> <span class="o">=</span> <span class="s1">&#39;removed&#39;</span>

    <span class="c1"># We don&#39;t actually use this ourselves anymore, but I&#39;m not 100% sure that</span>
    <span class="c1"># no-one else in the world is using it (though I hope not)</span>
    <span class="kn">from</span> <span class="nn">.testing</span> <span class="k">import</span> <span class="n">Tester</span>

    <span class="c1"># Pytest testing</span>
    <span class="kn">from</span> <span class="nn">numpy._pytesttester</span> <span class="k">import</span> <span class="n">PytestTester</span>
    <span class="n">test</span> <span class="o">=</span> <span class="n">PytestTester</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>
    <span class="k">del</span> <span class="n">PytestTester</span>


    <span class="k">def</span> <span class="nf">_sanity_check</span><span class="p">():</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Quick sanity checks for common bugs caused by environment.</span>
<span class="sd">        There are some cases e.g. with wrong BLAS ABI that cause wrong</span>
<span class="sd">        results under specific runtime conditions that are not necessarily</span>
<span class="sd">        achieved during test suite runs, and it is useful to catch those early.</span>

<span class="sd">        See https://github.com/numpy/numpy/issues/8577 and other</span>
<span class="sd">        similar bug reports.</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="n">x</span> <span class="o">=</span> <span class="n">ones</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="n">float32</span><span class="p">)</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="nb">abs</span><span class="p">(</span><span class="n">x</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">-</span> <span class="mf">2.0</span><span class="p">)</span> <span class="o">&lt;</span> <span class="mf">1e-5</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">AssertionError</span><span class="p">()</span>
        <span class="k">except</span> <span class="ne">AssertionError</span><span class="p">:</span>
            <span class="n">msg</span> <span class="o">=</span> <span class="p">(</span><span class="s2">&quot;The current Numpy installation (</span><span class="si">{!r}</span><span class="s2">) fails to &quot;</span>
                   <span class="s2">&quot;pass simple sanity checks. This can be caused for example &quot;</span>
                   <span class="s2">&quot;by incorrect BLAS library being linked in, or by mixing &quot;</span>
                   <span class="s2">&quot;package managers (pip, conda, apt, ...). Search closed &quot;</span>
                   <span class="s2">&quot;numpy issues for similar problems.&quot;</span><span class="p">)</span>
            <span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="n">msg</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="vm">__file__</span><span class="p">))</span>

    <span class="n">_sanity_check</span><span class="p">()</span>
    <span class="k">del</span> <span class="n">_sanity_check</span>
</pre></div>

           </div>
           
          </div>
          <footer>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2019, Argo AI, LLC

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>